using System;
using System.Text;
using System.Net;
using MIS.EN.Exchange.Entities;

namespace MIS.EN.Exchange
{
    internal class CalendarFolderWorker : FolderWorker<Appointment>
    {
        public CalendarFolderWorker(NetworkCredential credentials, bool useFormsBasedAuthentication, bool useIsaServer2006)
            : base(credentials, useFormsBasedAuthentication, useIsaServer2006)
        {
        }

        protected override void BuildContentClassNode(StringBuilder xmlBuilder)
        {
            xmlBuilder.Append("urn:content-classes:appointment");
        }

        protected override void BuildMessageClass(StringBuilder xmlBuilder)
        {
            xmlBuilder.Append("IPM.Appointment");
        }

        protected override string FolderName
        {
            get { return "Calendar"; }
        }

        protected override Type ItemType
        {
            get { return typeof(Appointment); }
        }

        protected override void SerializeProperties(StringBuilder xmlBuilder, Item item)
        {
            base.SerializeProperties(xmlBuilder, item);

            // This property determines appt or meeting (0 = appt) (This is NOT in the SDK schema!!!)
            xmlBuilder.Append("<mapi:apptstateflags dt:dt=\"int\">0</mapi:apptstateflags>");
        }

        protected override void BuildNamespaces(bool useWebDavReplication)
        {
            base.BuildNamespaces(useWebDavReplication);
            base.WebDavDocumentNamespaces.Add("cal", "urn:schemas:calendar:");
            base.WebDavDocumentNamespaces.Add("con", "urn:schemas:contacts:");
            base.WebDavDocumentNamespaces.Add("header", "urn:schemas:mailheader:");
            base.WebDavDocumentNamespaces.Add("mail", "urn:schemas:httpmail:");
            base.WebDavDocumentNamespaces.Add("mapi", "http://schemas.microsoft.com/mapi/");
            base.WebDavDocumentNamespaces.Add("mapit", "http://schemas.microsoft.com/mapi/proptag/");
        }

        protected override string PropertyMappingsFileName
        {
            get { return "MIS.EN.Exchange.PropertyMappings.AppointmentPropertyMappings.xml"; }
        }

        protected override bool UsesHexadecimalXmlNames
        {
            get { return false; }
        }
    }
}
